set
var/
$include ../define/variablelist_engage2.set
/

year/2050,2090/
cat3/
*"(Intercept)"
"CarbonBudget"
"Full_PeakPeak"
"ModelN"
"ModelNCOFFEE 1_1"
"ModelNGEM-E3_092019"
"ModelNIMAGE 3_0"
"ModelNMESSAGEix-GLOBIOM_1.0"
"ModelNPOLES_ENGAGE"
"ModelNREMIND-MAgPIE 2_0-4_1"
"ModelNWITCH 5_0"
/
cat3a(cat3)/
"CarbonBudget"
"Full_PeakPeak"
/
moddummy1(cat3)  model type/
"ModelNCOFFEE 1_1"
"ModelNGEM-E3_092019"
"ModelNIMAGE 3_0"
"ModelNMESSAGEix-GLOBIOM_1.0"
"ModelNPOLES_ENGAGE"
"ModelNREMIND-MAgPIE 2_0-4_1"
"ModelNWITCH 5_0"
/
cat4/
"coefficient"
"Std. Error"
"t-value"
"Pr>t"
"P_asterisk"
/
;

parameter
regression1(var,year,cat3,cat4)
regression1a(var,year,cat3,cat4)
moddummyave1(var,year)
;

$gdxin "../output/fig/ENGAGE/regression/reg1.gdx"
$load regression1

regression1a(var,year,cat3,"P_asterisk")$(cat3a(cat3) and regression1(var,year,cat3,"Pr>t")<0.05 and regression1(var,year,cat3,"Pr>t")>=0.01)=1;
regression1a(var,year,cat3,"P_asterisk")$(cat3a(cat3) and regression1(var,year,cat3,"Pr>t")<0.01 and regression1(var,year,cat3,"Pr>t")>=0.005)=2;
regression1a(var,year,cat3,"P_asterisk")$(cat3a(cat3) and regression1(var,year,cat3,"Pr>t")<0.005 and regression1(var,year,cat3,"Pr>t")>=0 and regression1(var,year,cat3,"coefficient"))=3;


regression1a(var,year,cat3,"Std. Error")$(cat3a(cat3))=regression1(var,year,cat3,"Std. Error");
regression1a(var,year,cat3,"coefficient")$(cat3a(cat3))=regression1(var,year,cat3,"coefficient");

moddummyave1(var,year)$sum(cat3$(moddummy1(cat3) and regression1(var,year,cat3,"coefficient")),1)
=sum(cat3$moddummy1(cat3),regression1(var,year,cat3,"coefficient"))/sum(cat3$(moddummy1(cat3) and regression1(var,year,cat3,"coefficient")),1);

*regression1b(var,year,"ModelN")$(regression1a(var,year,"ModelNMESSAGEix-GLOBIOM_1.0")=1 or regression1(var,year,"ModelNREMIND-MAgPIE 2_0-4_1","Pr>t")<0.05 and regression1(var,year,"ModelNWITCH 5_0","Pr>t")<0.05)=1;

execute_unload '../output/fig/ENGAGE/regression/reg1_summary.gdx'
regression1a
moddummyave1





